package com.twu.biblioteca.menu;

import com.twu.biblioteca.BibliotecaApp;
import com.twu.biblioteca.model.User;

/**
 * @author Aaron Edwards
 * @since 24/09/13
 *        Menu Item used to check the membership details.</br>
 *        This method currently only directs users to talk to the librarian
 */
public class CheckMembershipMenuItem implements IMenuItem {
    @Override
    public String getMenuTitleForUser(User currentUser) {
        return "Check Membership Details";
    }

    @Override
    public void doAction(BibliotecaApp bibliotecaApp) {

        User currentUser = bibliotecaApp.getCurrentUser();

        if (currentUser == null) {
            bibliotecaApp.getOutputStream().println("Please talk to a Librarian. Thank you.");
        } else {
            bibliotecaApp.getOutputStream().println(
                    String.format("%s\t%s\t%s", currentUser.getUsername(), currentUser.getEmail(), currentUser.getPhone())
            );
        }
    }
}
